package hotel_price;

import com.alibaba.fastjson.JSON;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class MapTest extends Mapper<LongWritable, Text,Text, IntWritable> {
    Text k = new Text();
    IntWritable v = new IntWritable();
    HotelData hotelData = new HotelData();
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        hotelData = JSON.parseObject(value.toString(),HotelData.class);
        k.set(hotelData.getCity_name());
        v.set(Integer.parseInt(hotelData.getPrice()));
        context.write(k,v);
    }
}
